package com.cbs.android.function.feedback.baichuan;

import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;

import com.alibaba.sdk.android.feedback.impl.FeedbackAPI;
import com.alibaba.sdk.android.feedback.util.IUnreadCountCallback;
import com.alibaba.sdk.android.feedback.util.k;
import com.cbs.android.component.log.L;

/**
 * Created by zyj on 2016/12/16.
 */

public class CBSFeedback {
	public static Context mContext;

	public static void init(Application application) {
		mContext = application.getApplicationContext();
		try {
			ApplicationInfo appInfo = application.getPackageManager()
					.getApplicationInfo(application.getPackageName(),
							PackageManager.GET_META_DATA);
			String msg = appInfo.metaData.get("BAICHUAN_KEY").toString();
			FeedbackAPI.init(application, msg);

		} catch (PackageManager.NameNotFoundException e) {
			e.printStackTrace();
		}
	}

	public static void openFeedbackActivity() {
		if (mContext == null) {
			L.e("CBSFeedback", "组件未初始化");
			return;
		}
		Intent intent = new Intent(mContext, CBSFeedbackActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		mContext.startActivity(intent);
	}

	public static void getFeedbackUnreadCount(IUnreadCountCallback callback) {
		FeedbackAPI.getFeedbackUnreadCount(callback);
	}

	public static void addErrorCallback(k var0) {
		FeedbackAPI.addErrorCallback(var0);
	}


}
